#!/usr/bin/perl


@text = (	"/*LICENSE_BEGIN\n",   # DO NOT CHANGE THIS LINE
		" * ******************************************************************\n",
		" * All original parts of SoccerScope2003 have copyright (2003) by\n",
		" * Team YowAI, represented by Mr. Shuhei Shiota\n",
		" * The Department of Creative Informatics\n",
		" * The Graduate School of Information Science and Technology\n",
		" * The University of Tokyo\n",
		" * \n",
		" * Additional classes (except libraries in /lib) were developed by \n",
		" * the Dainamite Robocup-Team of the DAI-Labor, TU-Berlin \n",
		" * (www.dai-labor.de)\n",
		" * \n",
		" * Extended/new classes/packages are:\n",
		" *   soccerscope.analyzer.LogfileAnalyzer\n",
		" *   soccerscope.daistatistic.*\n",
   		" *   soccerscope.daistatistic.charts.*\n",
		" *   soccerscope.daistatistic.tools.*\n",
		" *   soccerscope.db.*\n",
		" *   soccerscope.dialog.*\n",
		" *   soccerscope.model.PlayerWorldModel\n",
		" *   soccerscope.model.SimplePlayer\n",
		" *   soccerscope.net.AgentConnector\n",
		" *   soccerscope.training.*\n",
		" *   soccerscope.training.conditions.*\n",
		" * ******************************************************************\n",
		"LICENSE_END*/\n"); # DO NOT CHANGE THIS LINE
		
 changeDir('.');


###SUBS####

### fakultaet(Zahl)
# bestimme die Fakultaet einer Zahl
sub changeDir{
  my $dir=$_[0];

 # Verzeichnis lesen
opendir(DIR, $dir);
	my @dateien = readdir(DIR);
closedir(DIR);

# Addition oder Rekursion fuer alle gelesenen
foreach my $datei (@dateien) {
	next if ( ($datei eq '.') || ($datei eq '..'));
	my $pfadtotal = "$dir/$datei";
	if(-d $pfadtotal) {
		changeDir($pfadtotal);	
	} 
	if ($datei =~ /.java/) {

		print $pfadtotal."\n";

		open(INFILE, $pfadtotal);
			my @lines = <INFILE>;
		close(INFILE);
		
		open(OUTFILE, ">".$pfadtotal);
			print OUTFILE @text;
			my $license = 0;
			
			foreach $line (@lines) {
				if($line =~ /LICENSE_BEGIN/) {
					$license = 1;
				}
				if($license == 0) {
					print OUTFILE $line;
				}
				if($line =~ /LICENSE_END/) {
					$license = 0;
				}
			}
		close(INFILE);
		
	}
}

}		